package com.robot.goods.dao;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;

import com.robot.goods.pojo.GoodsCategory;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * category数据访问接口
 *
 * @author wuyunbin
 */
public interface GoodsCategoryDao extends JpaRepository<GoodsCategory, String>, JpaSpecificationExecutor<GoodsCategory> {
    /**
     * 查询全部并根据权重排序
     *
     * @return
     */
    @Query(value = "select * from goods.goods_category where deleted_at is null order by sort desc", nativeQuery = true)
    public List<GoodsCategory> findAllByDeletedAtIsNullAndOrderBySortDesc();

    /**
     * 通过name查询GoodsCategory
     *
     * @param name
     * @return
     */
    public GoodsCategory findByName(String name);
}
